home *** CD-ROM | disk | FTP | other *** search
- Path: news.production.compuserve.com!news
- From: Holger Maier <100336.3326@CompuServe.COM>
- Newsgroups: comp.lang.c++
- Subject: Q:order of evaluation
- Date: 16 Jan 1996 06:47:26 GMT
- Organization: DLZ Heidelberg
- Message-ID: <4dfhlu$a33$1@mhafn.production.compuserve.com>
-
- Consider
- #include <iostream>
- int main() {
- int i=1;int j=i+(i+=1);
- cout<<i<<','<<j<<'\n';
- return 0;
- }
- on my compiler this produces 2,4
- Looked up the ARM:
- 5: .. The order of evaluation of subexpressions is determined by the
- precedence and grouping of operators.
- 5.7: The additive operators + and - group left to right.
- So, j should be assigned 3 ??
- Now the question to you C++ gurus out there on the nets:
- Is it really a compiler bug or is it just me misinterpreting the
- ARM?
- BTW: I know we should not code like that...
- Holger
-